import { RuleItem } from '@/types/rules'
import { FormRules } from 'element-plus'
import { CSSProperties } from 'vue'

export type FormType =
  | 'autocomplete'
  | 'cascader'
  | 'checkbox'
  | 'checkbox-group'
  | 'color-picker'
  | 'date-picker'
  | 'input'
  | 'input-number'
  | 'radio'
  | 'radio-group'
  | 'rate'
  | 'select'
  | 'tree-select'
  | 'option'
  | 'slider'
  | 'switch'
  | 'time-picker'
  | 'time-select'
  | 'transfer'
  | 'upload'
  | 'editor'

export type TableColType = 'selection' | 'index' | 'expand'

export interface ColumnsTypes {
  type?: FormType
  colType?: TableColType
  value?: any
  searchValue?: any
  label?: string
  prop?: string
  showInSearch?: boolean
  hideInTable?: boolean
  hideInForm?: boolean
  rules?: RuleItem[]
  attrs?: {
    placeholder?: string
    size?: string
    clearable?: boolean
    disabled?: boolean
    style?: CSSProperties
    [x: string]: any
  }
  tableAttrs?: {
    [x: string]: any
  }
  data?: any
  children?: ColumnsTypes[]
  renderTableHeader?: (params: any) => any
  [x: string]: any
}

export interface PageProps {
  current: number
  size: number
  total: number
}

export interface ProTableParams {
  loading: boolean
  searchColumns: ColumnsTypes[]
  searchModel: {
    [x: string]: any
  }
  settingColumns: ColumnsTypes[]
  tableColumns: ColumnsTypes[]
  tableData: any
  pageSizes: number[]
  pagination: PageProps
  [x: string]: any
}

/** 需要导出的参数或方法要写出来，否则是获取不到 */
export interface FormItemParams {
  id: number
  isAdd: boolean
  readonly: boolean
  visibleDrawer: boolean
  formColumns: ColumnsTypes[]
  model: {
    [x: string]: any
  }
  rules: FormRules
  [x: string]: any
}

/** 表格配置 */
export interface TableSettingsParams {
  tableColumns: ColumnsTypes[]
  [x: string]: any
}
